import { createStore } from 'vuex'

//Vuex.Store 构造器选项
const store = createStore({
    state:{//存放状态
        favor: {
			fund: uni.getStorageSync('favor').fund || [],
			stock: uni.getStorageSync('favor').stock || []
        },
        holding: {
        	fund: uni.getStorageSync('holding').fund || [],
        	stock: uni.getStorageSync('holding').stock || []
        }
    },
	getters: {
		favor: state=>{return state.favor},
		holding: state=>{return state.holding},
	},
	mutations: {
		setFavor: (state, data)=>{
			state.favor = data;
			uni.setStorageSync('favor', data)
		},
		setHolding: (state, data)=>{
			state.holding = data
			uni.setStorageSync('holding', data)
		},
	}
})
export default store